package com.pastquestion;

public class Main10d {
	public static void main(String[] args) {
		int res = 0;
		for (int i = 1; i < 2019; i++) {
			for (int j = i + 1; j < 2019; j++) {
				int n = 2019 - i - j;
				if(isContain(i) && isContain(j) && isContain(n) && j > i && n > j && n > i)
					res++;
			}
		}
		System.out.println(res);
	}
	public static boolean isContain(int x) {
		while(x > 0)
		{
			int n = x % 10;
			if(n == 2 || n == 4)
				return false;
			x = x/10;
		}
		return true;
	}
}
